package com.yuw.dz;

public class Student implements Comparable<Student> {
    // 属性
    private String stuName;
    private int stuScore;

    // 行为


    public Student(String stuName, int stuScore) {
        this.stuName = stuName;
        this.stuScore = stuScore;
    }

    public Student() {
    }

    /**
     * 学习行为
     */
    public void doStuding() {
        System.out.println("I am studing...");
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public int getStuScore() {
        return stuScore;
    }

    public void setStuScore(int stuScore) {
        this.stuScore = stuScore;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuName='" + stuName + '\'' +
                ", stuScore=" + stuScore +
                '}';
    }

    @Override
    public int compareTo(Student stu) {
        // 要求根据排序比较的业务逻辑返回三种值 -1 0 1
        int i = 0; // 根据业务初始化
        // 大于
        if (this.stuScore > stu.getStuScore()) {
            // this表示当前对象  stu表示比较的对象
            // 大于
            i = 1;
        } else if (this.stuScore < stu.getStuScore()) {
            // 小于
            i = -1;
        } else {
            // 等于
            i = 0;
        }
        // 返回比较结果的三种值
        return i * (-1);
    }
}
